<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_device';
	$filename = 'admin/admin_device_add';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('device');
	require_once $_site->get_handlepath('admin');
	$id= request('id',false,true);
	$result = device_fun_get_device_info($id);
	
	$admin_obj = new admin();
	$user_info = $admin_obj->out_cookie();	
	if(6==$user_info['group']){
		require_once $_site->get_handlepath('admin');
		$master_list=admin_fun_list(array('master'=>true),1,10);	
	}	
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main','my97/wdatepicker'],
		skincss:['list']
	});
	$(document).ready(function(){

		var form_obj=$("#form1").Validform({
		   tiptype: function(msg, o, cssctl){
			   if(!o.obj.is("form")){
				   var obj = o.obj.parent("td").find('tt');
				   cssctl(obj, o.type);
				   obj.text(msg);
			   }
		   },
		   ajaxPost:true,
		   callback:function (data){
				dialog.finish({
					content:data.msg,
					success:data.state,
					/*timeout:10000000,*/
					callback:function (){

						if(data.state){
							<?php if(6==$user_info['group']){ ?>							
							window.location.href='/admin/admin_device_list'
							<?php }else{ ?>
							window.location.reload(true);
							<?php }?>	
						}

					}
				})
		   }
		})
	})
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?> &gt; <?php echo $result['id']?'编辑设备':'添加设备' ;?></div>
		<div class="main">
			<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="device/add">
			<input type="hidden" name="id" value="<?php echo $result['id']?>">
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text">

				<tr>
					<td class="left">手机设备编号：</td>
					<td>
						<input type="text" class='w260' name='no' value="<?php echo $result['no'] ;?>" datatype='s6-20' <?php echo !$result['id']?"ajaxurl='/handle.php?h=device/unique'":'' ;?>  errormsg='格式为6-20位字符' nullmsg='请输入手机设备编号'><span class='comment'></span><tt></tt>
					</td>
				</tr>
				
				<?php 
				  if(6==$user_info['group']){
				?>
				<tr>
					<td class="left">项目经理：</td>
					<td>
				    <select name='master'>
					   <option value="0">请选择</option>
					      <?php 
					      if($master_list){
					      foreach($master_list as $key=>$val){
                          ?>
                             <option value="<?php echo $val['id']?>" <?php if($val['id']==$result['master']){echo "selected";} ?>><?php echo $val['name']?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>					
					<tt>指定后，该设备只会由这个项目经理查看使用</tt>
					</td>
				</tr>			
				
				<tr>
					<td class="left">归属：</td>
					<td>
                       <label><input type="radio" name="own" <?php echo ($result&&0==$result['own'])?'checked':'' ?> value="0">平台</label>&nbsp;&nbsp;						
                       <label><input type="radio" name="own" <?php echo ($result&&1==$result['own'])?'checked':'' ?> value="1">项目经理</label>
                       <tt>即该设备归谁所有</tt>
					</td>
				</tr>				
					
				<?php 
				}
				?>												
				
				<tr>
					<td></td>
					<td>
						<input class="button1" type="submit" value="<?php echo $result['id']?'修改':'添加' ;?>">
					</td>
				</tr>

			</table>
			</form>
		</div>
	</div>
</body>
</html>




